import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;


public class JDBC_Tibero {
	
	
	public static void main(String[] args) throws SQLException {
		
		System.out.println( "java.library.path = " + System.getProperty( "java.library.path"));
		
		try {
			Class.forName( "com.tmax.tibero.jdbc.TbDriver");

		} catch ( ClassNotFoundException e1) {
			e1.printStackTrace();

		}

		Properties dbProperties = new Properties();
		
		dbProperties.setProperty( "user", "bizteco");
		dbProperties.setProperty( "password", "btc7btc");
		Connection conn = null;
		java.sql.PreparedStatement pstmt = null;
		java.sql.ResultSet rs = null;
		
		// Added
		DatabaseMetaData dbMetaData = null;
		 
		try {
//			conn = DriverManager.getConnection( "jdbc:tibero:thin:@192.168.0.30:8629:tibero", dbProperties);
			conn = DriverManager.getConnection( "jdbc:tibero:thin:@demoserver:8629:tibero", dbProperties);
//			conn = DriverManager.getConnection( "jdbc:tibero:thin:@demoserver:8629:tibero", "bizteco", "btc7btc");
			System.out.println( "DB Connected.");
			
			dbMetaData = conn.getMetaData();
			boolean supportsBatchUpdates = dbMetaData.supportsBatchUpdates();
			System.out.println( "supportsBatchUpdates=" + supportsBatchUpdates);
			
//			/* SELECT */
			pstmt = conn.prepareStatement( "SELECT * FROM KIS_MENU2");
			rs = pstmt.executeQuery();
			
			while( rs.next()) {
				System.out.println( "EMPNO = " + rs.getInt(1));
			}
			
//			/* SELECT */
//			pstmt = conn.prepareStatement( "SELECT ORG_CD, MENU_CD, SEQ FROM BMT_MENU");
//			rs = pstmt.executeQuery();
//			while( rs.next()) {
//				
//				System.out.println( "ORG_CD = " + rs.getString(1));
//				System.out.println( "MENU_CD = " + rs.getString(2));
//				System.out.println( "SEQ = " + rs.getInt(3));
//			}
			
			
//			/* INSERT ( 1 by 1) */
//			pstmt = conn.prepareStatement( "INSERT INTO BMT_MENU(ORG_CD, MENU_CD, SEQ) VALUES ( '1111', '1111', ?)");
//			for( int i = 6000; i < 6010; i++) {
//				pstmt.setInt( 1, i);
//				pstmt.executeUpdate();
//			}
//			conn.commit();
			
			
			/* INSERT ( Batch) */
//			pstmt = conn.prepareStatement( "INSERT INTO BMT_MENU(ORG_CD, MENU_CD, SEQ) VALUES ( '1111', '1111', ?)");
//			for( int i = 6000; i < 6010; i++) {
//				pstmt.setInt( 1, i);
//				pstmt.addBatch();
//				pstmt.clearParameters();
//			}
//			int[] resCode = pstmt.executeBatch();
//			conn.commit();
//			pstmt.clearBatch();
			
//			for( int ll = 0; ll < resCode.length; ll++) {
//				if( resCode[ ll] != 0)
//					System.out.println( "Error[" + ll + "] = " + resCode[ ll]);
//			}
			
		} catch( Exception e) {
			e.printStackTrace();
		
		}
	}
}
